package edu.nctu.csie.jichang.database.util;

import java.io.File;
import java.io.FileWriter;

import org.dom4j.Document;
import org.dom4j.io.OutputFormat;
import org.dom4j.io.XMLWriter;

public class XMLUtil {

	private static OutputFormat format = OutputFormat.createPrettyPrint();
	
	public static void documentToFile(Document pDocument,File pLocation) throws Exception {
		if(!pLocation.getParentFile().exists()) pLocation.getParentFile().mkdirs();
		XMLWriter tWriter = new XMLWriter(new FileWriter(pLocation),format);
		tWriter.write(pDocument);
		tWriter.close();
	}
}